﻿using System;
using System.Runtime.InteropServices;

namespace KD.Sms.Controls
{
    internal class PlayCtrl
    {

        public struct FRAME_POS
        {
            public int nFilePos;

            public int nFrameNum;

            public int nFrameTime;

            public int nErrorFrameNum;

            public IntPtr pErrorTime;

            public int nErrorLostFrameNum;

            public int nErrorFrameSize;

            public void Init()
            {
                nFilePos = 0;
                nFrameNum = 0;
                nFrameTime = 0;
                nErrorFrameNum = 0;
                pErrorTime = default(IntPtr);
                nErrorLostFrameNum = 0;
                nErrorFrameSize = 0;
            }
        }

        public struct FRAME_INFO
        {
            public int nWidth;

            public int nHeight;

            public int nStamp;

            public int nType;

            public int nFrameRate;

            public uint dwFrameNum;

            public void Init()
            {
                nWidth = 0;
                nHeight = 0;
                nStamp = 0;
                nType = 0;
                nFrameRate = 0;
                dwFrameNum = 0u;
            }
        }

        public struct FRAME_TYPE
        {
            [MarshalAs(UnmanagedType.LPStr)]
            public string pDataBuf;

            public int nSize;

            public int nFrameNum;

            public bool bIsAudio;

            public int nReserved;

            public void Init()
            {
                pDataBuf = "";
                nSize = 0;
                nFrameNum = 0;
                bIsAudio = false;
                nReserved = 0;
            }
        }

        public struct WATERMARK_INFO
        {
            [MarshalAs(UnmanagedType.LPStr)]
            public string pDataBuf;

            public int nSize;

            public int nFrameNum;

            public bool bRsaRight;

            public int nReserved;

            public void Init()
            {
                pDataBuf = "";
                nSize = 0;
                nFrameNum = 0;
                bRsaRight = false;
                nReserved = 0;
            }
        }

        public struct HIK_MEDIAINFO
        {
            public uint media_fourcc;

            public ushort media_version;

            public ushort device_id;

            public ushort system_format;

            public ushort video_format;

            public ushort audio_format;

            public byte audio_channels;

            public byte audio_bits_per_sample;

            public uint audio_samplesrate;

            public uint audio_bitrate;

            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4, ArraySubType = UnmanagedType.U4)]
            public uint[] reserved;

            public void Init()
            {
                media_fourcc = 0u;
                media_version = 0;
                device_id = 0;
                system_format = 0;
                video_format = 0;
                audio_format = 0;
                audio_channels = 0;
                audio_bits_per_sample = 0;
                audio_samplesrate = 0u;
                audio_bitrate = 0u;
                reserved = new uint[4];
            }
        }

        public delegate void DECCBFUN(int nPort, IntPtr pBuf, int nSize, ref FRAME_INFO pFrameInfo, int nReserved1, int nReserved2);

        public delegate void DISPLAYCBFUN(int nPort, IntPtr pBuf, int nSize, int nWidth, int nHeight, int nStamp, int nType, int nReserved);

        public delegate void SOURCEBUFCALLBACKI(int nPort, uint nBufSize, uint dwUser, IntPtr pResvered);

        public delegate void PFILEREFDONE(uint nPort, uint nUser);

        public struct tagRECT
        {
            public int left;

            public int top;

            public int right;

            public int bottom;

            public void Init()
            {
                left = 0;
                top = 0;
                right = 0;
                bottom = 0;
            }
        }

        public delegate void DRAWFUN(int nPort, IntPtr hDc, int nUser);

        public delegate void FUNVERYFY(int nPort, ref FRAME_POS pFilePos, uint bIsVideo, uint nUser);

        public delegate void FUNAUDIO(int nPort, string pAudioBuf, int nSize, int nStamp, int nType, int nUser);

        public delegate void FUNENCCHANGE(int nPort, int nUser);

        public delegate void FUNGETORIGNALFRAME(int nPort, ref FRAME_TYPE frameType, int nUser);

        public delegate void FUNCHECKWATERMARK(int nPort, ref WATERMARK_INFO pWatermarkInfo, uint nUser);

        public delegate void FUNTHROWBFRAME(int nPort, uint nBFrame, uint nUser);

        public delegate void FUNGETUSERDATA(int nPort, ref byte pUserBuf, uint nBufLen, uint nUser);

        public delegate void FILEENDCALLBACK(int nPort, IntPtr pUser);

        public const string PLAYM4_API = "extern \"C\"__declspec(dllexport)";

        public const int PLAYM4_MAX_SUPPORTS = 500;

        public const int MIN_WAVE_COEF = -100;

        public const int MAX_WAVE_COEF = 100;

        public const int TIMER_1 = 1;

        public const int TIMER_2 = 2;

        public const int BUF_VIDEO_SRC = 1;

        public const int BUF_AUDIO_SRC = 2;

        public const int BUF_VIDEO_RENDER = 3;

        public const int BUF_AUDIO_RENDER = 4;

        public const int PLAYM4_NOERROR = 0;

        public const int PLAYM4_PARA_OVER = 1;

        public const int PLAYM4_ORDER_ERROR = 2;

        public const int PLAYM4_TIMER_ERROR = 3;

        public const int PLAYM4_DEC_VIDEO_ERROR = 4;

        public const int PLAYM4_DEC_AUDIO_ERROR = 5;

        public const int PLAYM4_ALLOC_MEMORY_ERROR = 6;

        public const int PLAYM4_OPEN_FILE_ERROR = 7;

        public const int PLAYM4_CREATE_OBJ_ERROR = 8;

        public const int PLAYM4_CREATE_DDRAW_ERROR = 9;

        public const int PLAYM4_CREATE_OFFSCREEN_ERROR = 10;

        public const int PLAYM4_BUF_OVER = 11;

        public const int PLAYM4_CREATE_SOUND_ERROR = 12;

        public const int PLAYM4_SET_VOLUME_ERROR = 13;

        public const int PLAYM4_SUPPORT_FILE_ONLY = 14;

        public const int PLAYM4_SUPPORT_STREAM_ONLY = 15;

        public const int PLAYM4_SYS_NOT_SUPPORT = 16;

        public const int PLAYM4_FILEHEADER_UNKNOWN = 17;

        public const int PLAYM4_VERSION_INCORRECT = 18;

        public const int PLAYM4_INIT_DECODER_ERROR = 19;

        public const int PLAYM4_CHECK_FILE_ERROR = 20;

        public const int PLAYM4_INIT_TIMER_ERROR = 21;

        public const int PLAYM4_BLT_ERROR = 22;

        public const int PLAYM4_UPDATE_ERROR = 23;

        public const int PLAYM4_OPEN_FILE_ERROR_MULTI = 24;

        public const int PLAYM4_OPEN_FILE_ERROR_VIDEO = 25;

        public const int PLAYM4_JPEG_COMPRESS_ERROR = 26;

        public const int PLAYM4_EXTRACT_NOT_SUPPORT = 27;

        public const int PLAYM4_EXTRACT_DATA_ERROR = 28;

        public const int PLAYM4_SECRET_KEY_ERROR = 29;

        public const int MAX_DISPLAY_WND = 4;

        public const int DISPLAY_NORMAL = 1;

        public const int DISPLAY_QUARTER = 2;

        public const int MAX_DIS_FRAMES = 50;

        public const int MIN_DIS_FRAMES = 1;

        public const int BY_FRAMENUM = 1;

        public const int BY_FRAMETIME = 2;

        public const int SOURCE_BUF_MAX = 102400000;

        public const int SOURCE_BUF_MIN = 51200;

        public const int STREAME_REALTIME = 0;

        public const int STREAME_FILE = 1;

        public const int T_AUDIO16 = 101;

        public const int T_AUDIO8 = 100;

        public const int T_UYVY = 1;

        public const int T_YV12 = 3;

        public const int T_RGB32 = 7;

        public const int SUPPORT_DDRAW = 1;

        public const int SUPPORT_BLT = 2;

        public const int SUPPORT_BLTFOURCC = 4;

        public const int SUPPORT_BLTSHRINKX = 8;

        public const int SUPPORT_BLTSHRINKY = 16;

        public const int SUPPORT_BLTSTRETCHX = 32;

        public const int SUPPORT_BLTSTRETCHY = 64;

        public const int SUPPORT_SSE = 128;

        public const int SUPPORT_MMX = 256;

        public const int FOURCC_HKMI = 1212894537;

        public const int SYSTEM_NULL = 0;

        public const int SYSTEM_HIK = 1;

        public const int SYSTEM_MPEG2_PS = 2;

        public const int SYSTEM_MPEG2_TS = 3;

        public const int SYSTEM_RTP = 4;

        public const int VIDEO_NULL = 0;

        public const int VIDEO_H264 = 1;

        public const int VIDEO_MPEG4 = 3;

        public const int AUDIO_NULL = 0;

        public const int AUDIO_ADPCM = 4096;

        public const int AUDIO_MPEG = 8192;

        public const int AUDIO_G711_U = 28944;

        public const int AUDIO_G711_A = 28945;

        public const int AUDIO_G722_1 = 29217;

        public const int AUDIO_G723_1 = 29233;

        public const int AUDIO_G726 = 29280;

        public const int AUDIO_G729 = 29328;

        public static DateTime ConverUiTimeToDateTime(uint uiTime)
        {
            int year = (int)((uiTime >> 26) + 2000);
            int month = (int)((uiTime >> 22) & 0xF);
            int day = (int)((uiTime >> 17) & 0x1F);
            int hour = (int)((uiTime >> 12) & 0x1F);
            int minute = (int)((uiTime >> 6) & 0x3F);
            int second = (int)(uiTime & 0x3F);
            return new DateTime(year, month, day, hour, minute, second);
        }

        public static void GetTimeFromUiTime(uint uiTime, ref uint uiHour, ref uint uiMinute, ref uint uiSecond)
        {
            uiHour = ((uiTime >> 12) & 0x1F);
            uiMinute = ((uiTime >> 6) & 0x3F);
            uiSecond = (uiTime & 0x3F);
        }

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_InitDDraw(IntPtr hWnd);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_RealeseDDraw();

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_OpenFile(int nPort, string sFileName);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_CloseFile(int nPort);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_Play(int nPort, IntPtr hWnd);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_Stop(int nPort);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_Pause(int nPort, uint nPause);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_Fast(int nPort);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_Slow(int nPort);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_OneByOne(int nPort);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_SetPlayPos(int nPort, float fRelativePos);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern float PlayM4_GetPlayPos(int nPort);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_SetFileEndMsg(int nPort, IntPtr hWnd, uint nMsg);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_SetVolume(int nPort, ushort nVolume);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_StopSound();

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_PlaySound(int nPort);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_OpenStream(int nPort, IntPtr pFileHeadBuf, uint nSize, uint nBufPoolSize);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_InputData(int nPort, IntPtr pBuf, uint nSize);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_CloseStream(int nPort);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern int PlayM4_GetCaps();

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern uint PlayM4_GetFileTime(int nPort);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_GetFileTimeEx(int nPort, ref uint pStart, ref uint pStop, ref uint pRev);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern uint PlayM4_GetPlayedTime(int nPort);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern uint PlayM4_GetPlayedFrames(int nPort);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_SetDecCallBack(int nPort, DECCBFUN DecCBFun);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_SetDisplayCallBack(int nPort, DISPLAYCBFUN DisplayCBFun);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PLayM4_ConvertToBmpFile(IntPtr pBuf, int nSize, int nWidth, int nHeight, int nType, string sFileName);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern uint PlayM4_GetFileTotalFrames(int nPort);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern uint PlayM4_GetCurrentFrameRate(int nPort);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern uint PlayM4_GetPlayedTimeEx(int nPort);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_SetPlayedTimeEx(int nPort, uint nTime);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern uint PlayM4_GetCurrentFrameNum(int nPort);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_SetStreamOpenMode(int nPort, uint nMode);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern uint PlayM4_GetFileHeadLength();

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern uint PlayM4_GetSdkVersion();

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern uint PlayM4_GetLastError(int nPort);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_RefreshPlay(int nPort);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_SetOverlayMode(int nPort, int bOverlay, uint colorKey);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_GetPictureSize(int nPort, ref int pWidth, ref int pHeight);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_SetPicQuality(int nPort, int bHighQuality);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_PlaySoundShare(int nPort);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_StopSoundShare(int nPort);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern int PlayM4_GetStreamOpenMode(int nPort);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern int PlayM4_GetOverlayMode(int nPort);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern uint PlayM4_GetColorKey(int nPort);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern ushort PlayM4_GetVolume(int nPort);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_GetPictureQuality(int nPort, ref int bHighQuality);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern uint PlayM4_GetSourceBufferRemain(int nPort);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_ResetSourceBuffer(int nPort);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_SetSourceBufCallBack(int nPort, uint nThreShold, SOURCEBUFCALLBACKI SourceBufCallBack, uint dwUser, IntPtr pReserved);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_ResetSourceBufFlag(int nPort);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_SetDisplayBuf(int nPort, uint nNum);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern uint PlayM4_GetDisplayBuf(int nPort);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_OneByOneBack(int nPort);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_SetFileRefCallBack(int nPort, PFILEREFDONE pFileRefDone, uint nUser);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_GetKeyFramePos(int nPort, uint nValue, uint nType, ref FRAME_POS pFramePos);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_GetNextKeyFramePos(int nPort, uint nValue, uint nType, ref FRAME_POS pFramePos);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_InitDDrawDevice();

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern void PlayM4_ReleaseDDrawDevice();

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern uint PlayM4_GetDDrawDeviceTotalNums();

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_SetDDrawDevice(int nPort, uint nDeviceNum);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern int PlayM4_GetCapsEx(uint nDDrawDeviceNum);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_ThrowBFrameNum(int nPort, uint nNum);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_SetDisplayType(int nPort, int nType);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern int PlayM4_GetDisplayType(int nPort);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_SetDecCBStream(int nPort, uint nStream);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_SetDisplayRegion(int nPort, uint nRegionNum, ref tagRECT pSrcRect, IntPtr hDestWnd, [MarshalAs(UnmanagedType.Bool)] bool bEnable);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_RefreshPlayEx(int nPort, uint nRegionNum);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_SetDDrawDeviceEx(int nPort, uint nRegionNum, uint nDeviceNum);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_GetRefValue(int nPort, ref byte pBuffer, ref uint pSize);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_SetRefValue(int nPort, ref byte pBuffer, uint nSize);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_OpenStreamEx(int nPort, ref byte pFileHeadBuf, uint nSize, uint nBufPoolSize);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_CloseStreamEx(int nPort);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_InputVideoData(int nPort, IntPtr pBuf, uint nSize);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_InputAudioData(int nPort, ref byte pBuf, uint nSize);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_RigisterDrawFun(int nPort, DRAWFUN DrawFun, int nUser);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_RegisterDrawFun(int nPort, DRAWFUN DrawFun, int nUser);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_SetTimerType(int nPort, uint nTimerType, uint nReserved);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_GetTimerType(int nPort, ref uint pTimerType, ref uint pReserved);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_ResetBuffer(int nPort, uint nBufType);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern uint PlayM4_GetBufferValue(int nPort, uint nBufType);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_AdjustWaveAudio(int nPort, int nCoefficient);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_SetVerifyCallBack(int nPort, uint nBeginTime, uint nEndTime, FUNVERYFY funVerify, uint nUser);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_SetAudioCallBack(int nPort, FUNAUDIO funAudio, int nUser);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_SetEncTypeChangeCallBack(int nPort, FUNENCCHANGE funEncChange, int nUser);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_SetColor(int nPort, uint nRegionNum, int nBrightness, int nContrast, int nSaturation, int nHue);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_GetColor(int nPort, uint nRegionNum, ref int pBrightness, ref int pContrast, ref int pSaturation, ref int pHue);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_SetEncChangeMsg(int nPort, IntPtr hWnd, uint nMsg);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_GetOriginalFrameCallBack(int nPort, int bIsChange, int bNormalSpeed, int nStartFrameNum, int nStartStamp, int nFileHeader, FUNGETORIGNALFRAME funGetOrignalFrame, int nUser);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_GetFileSpecialAttr(int nPort, ref uint pTimeStamp, ref uint pFileNum, ref uint pReserved);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern uint PlayM4_GetSpecialData(int nPort);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_SetCheckWatermarkCallBack(int nPort, FUNCHECKWATERMARK funCheckWatermark, uint nUser);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_SetImageSharpen(int nPort, uint nLevel);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_GetThrowBFrameCallBack(int nPort, FUNTHROWBFRAME funThrowBFrame, uint nUser);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_SetDecodeFrameType(int nPort, uint nFrameType);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_SetPlayMode(int nPort, int bNormal);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_SetGetUserDataCallBack(int nPort, FUNGETUSERDATA funGetUserData, uint nUser);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_SetOverlayFlipMode(int nPort, int bTrue);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern uint PlayM4_GetAbsFrameNum(int nPort);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_ConvertToJpegFile(IntPtr pBuf, int nSize, int nWidth, int nHeight, int nType, string sFileName);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_SetJpegQuality(int nQuality);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_SetDeflash(int nPort, int bDefalsh);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_CheckDiscontinuousFrameNum(int nPort, int bCheck);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_GetBMP(int nPort, ref byte pBitmap, uint nBufSize, ref uint pBmpSize);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_GetJPEG(int nPort, IntPtr pJpeg, uint nBufSize, ref uint pJpegSize);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_SetDecCallBackMend(int nPort, DECCBFUN DecCBFun, int nUser);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_SetSecretKey(int nPort, int lKeyType, string pSecretKey, int lKeyLen);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_SetFileEndCallback(int nPort, FILEENDCALLBACK FileEndCallback, IntPtr pUser);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_GetPort(ref int nPort);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_FreePort(int nPort);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_SyncToAudio(int nPort, int bSyncToAudio);

        [DllImport("..\\bin\\PlayCtrl.dll")]
        public static extern bool PlayM4_SetDecCallBackEx(int nPort, DECCBFUN DecCBFun, IntPtr pDest, int nDestSize);
    }

}
